<template>
  <div id="app">
    <router-view />
  </div>
</template>

<script>
export default {
  name: "App",
  computed: {
    alertCont() {
      return this.$websocket.getters.onEvent();
    }
  },
  watch: {
    alertCont: function(a, b) {
      if (a != b && a) {
        console.log("触发事件：");
        console.log("a:" + a);
        console.log(a);
        // let b = JSON.parse(a)

        // console.log(b)
        this.$notify({
          title: a.title,
          message: a.body + a.time,
          duration: 0
        });
      }
    }
  },
  created() {
    if (localStorage.getItem("username")) {
      this.$websocket.dispatch(
        "WEBSOCKET_INIT",
        "ws://localhost:9996/ws/" + localStorage.getItem("username")
      );
    }
  }
};
</script>
